import axios from 'axios';
import apiClient from '@/services/axiosConfig';
import router from '@/router';

export const loginApi = async (data) => {

    try {
        const response = await axios.post('http://localhost:9000/user/login',data)
        return response.data;
    } catch (error) {
        console.error(error)
    }
}

export const registerApi = async (data) => {

    try {
        const response = await axios.post('http://localhost:9000/user/register',data)
        return response.data
    } catch (error) {
        console.error(error)
    }
}

export const payApi = async (id,amount) => {
    let token = localStorage.getItem('token')
    token = token.replace(/"/g, '');

    try {
        const response = await axios.post(`http://localhost:9000/user/pay?userId=${id}&amount=${amount}`,{
            headers: {
              Authorization: `Bearer ${token}`
            }
          })
        return response.data
    } catch (error) {
        console.error(error)
    }
}




